<h1 class="text-center"><?php echo __("Quote Bookmaker"); ?></h1>
		
<div id="country" data-country='<?php echo $country; ?>' ></div>
<div id="matchid" data-match='<?php echo $matchid; ?>' ></div>
<div id="webroot" data-url='<?php echo $this->webroot; ?>' ></div>
          
<?php 

$xml=simplexml_load_file("http://www.goalserve.com/getfeed/18945090b13942a5834efeec7eb903e2/soccer_odds/".$country."_shedule");

// $xml="";

$localteamId = null;
$localteam = null;
$visitorteamId = null;
$visitorteam = null;
$tournament = null;

if ($xml!=null) {

foreach($xml->category as $category){ ?>
	<? foreach($category->matches->match as $match){
		if ($matchid==$match->attributes()->static_id) {
			$localteamId=$match->localteam->attributes()->id;
			$localteam=$match->localteam->attributes()->name;
			$visitorteamId=$match->visitorteam->attributes()->id;
			$visitorteam=$match->visitorteam->attributes()->name;
			$tournament=$category->attributes()->name;
	?>
	
			<div class="tournament container-fluid">
			        <div class="body-tournament-live row">
							<div class="col-md-12" data-static-id="">
							        <div class="row">
			                            <div class="stats col-md-1"><h3><a class='stats' title="<?php echo __("Statistiche"); ?>" href="<?php echo $this->webroot.Configure::read("Config.lang"); ?>/stats/match/<?php echo $localteamId; ?>/<?php echo $visitorteamId; ?>"><i class="glyphicon glyphicon-stats"></i></a></h3></div>
							            <div class="localteam  col-md-3"><h3><?php echo $localteam; ?></h3></div>
							            <div class="date col-md-4"><h3><?php echo $match->attributes()->formatted_date . " " . $match->attributes()->time; ?></h3></div>
							            <div class="visitorteam col-md-3"><h3><?php echo $visitorteam; ?></h3></div>
			                            <div class="stats col-md-1"><h3><a class='stats' title="<?php echo __("Statistiche"); ?>" href="<?php echo $this->webroot.Configure::read("Config.lang"); ?>/stats/match/<?php echo $localteamId; ?>/<?php echo $visitorteamId; ?>"><i class="glyphicon glyphicon-stats"></i></a></h3></div>
							        </div>
							</div>
							<!-- ODDS -->
							<div class="odds col-md-12" data-static-id="" style="padding-top: 20px;">
								<div class="odds-type row">
									<div class="col-md-12">
									   <!-- Nav tabs -->
									    <ul class="nav nav-tabs">
									      <li class="active 3wayresult"><a href="#3wayresult" data-toggle="tab">1X2</a></li>
									    </ul>
									    <!-- Tab panes -->
									    <div class="tab-content">
									    	
									      <?php foreach ($match->odds->type as $type) { ?>
									      	  <?php if ($type->attributes()->id==1) { ?>
												  <!-- Type 3Way Result -->
											      <div class="tab-pane fade in active 3wayresult" id="3wayresult">
													<table class="table table-condensed odd-3wayresult-table">
													      <thead>
													        <tr>
													          <th style="text-align: center;"><?php echo __("Bookmaker"); ?></th>
													          <th style="text-align: center;"><?php echo __("1"); ?></th>
													          <th style="text-align: center;"><?php echo __("X"); ?></th>
													          <th style="text-align: center;"><?php echo __("2"); ?></th>
													        </tr>
													      </thead>
													      <tbody>
													         <?php foreach ($type->bookmaker as $bookmaker) { ?>
													            <tr class="odd-3wayresult-row">
													            	<td class="bookmaker-name"><?php echo $bookmaker->attributes()->name; ?></td>
													            	<td class="bookmaker-odd-1"><?php echo $bookmaker->odd[0]->attributes()->value; ?></td>
													            	<td class="bookmaker-odd-X"><?php echo $bookmaker->odd[2]->attributes()->value; ?></td>
													            	<td class="bookmaker-odd-2"><?php echo $bookmaker->odd[1]->attributes()->value; ?></td>
													            </tr>
													         <?php } ?>
													      </tbody>
													</table>  
											      	
											      </div>
											  <?php } ?>
											  <!-- Home / Away -->
									      <?php } ?>  
									      
									    </div>
									 </div>
								</div>
							</div>
							
			        </div>
			</div>
	<?php 
		break;
		}
	} ?>
	<?php } ?>

<?php } ?>

<script>

    $(document).ready(function() {
		setMax3wayresult('1');
		setMax3wayresult('2');
		setMax3wayresult('X');
    });

    function setMax3wayresult(type) {
    	valore=0;
    	oggetti = new Array();
        $('.odd-3wayresult-row').each(function() {
        	oggetto=$(this).children('td.bookmaker-odd-'+type);
        	if (valore==0) {
	        	valore = parseFloat(oggetto.html());
	        	oggetti.push(oggetto);
        	} else if (valore<parseFloat(oggetto.html())) {
	        	valore = parseFloat(oggetto.html());
	        	oggetti=new Array();
	        	oggetti.push(oggetto);
	        } else if (valore==parseFloat(oggetto.html())) {
	        	oggetti.push(oggetto);
	        }
        });
		$(oggetti).each(function() {
	        // console.log($(this));
		    $(this).addClass('td-max');
		});
    }

</script>